package com.yu.crm.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 模块名称：
 * 功能说明： 拦截放行
 * @Author: song
 */

@Configuration
public class MVCConfig extends WebMvcConfigurerAdapter {

    @Bean
    public HandlerInterceptor getTokenInterceptor(){
        return new InterceptorConfig();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getTokenInterceptor())
                .excludePathPatterns("/crm-login/login"
                        ,"/user/register","/template/download",
                        "/file/download","/template/export","/doc.html","/static/**")
                .excludePathPatterns("/pro-software/*")
                .excludePathPatterns("/crm-device/device-status")
                .excludePathPatterns("/ticketinfo/test")
                .excludePathPatterns("/ticketinfo/selectTicket")
                .excludePathPatterns("/ticketStatus/save")
                .excludePathPatterns("/ticketinfo/save")
                .excludePathPatterns("/shift/save")
                .excludePathPatterns("/vehicle/save")
                .excludePathPatterns("/img/upload2")
                .excludePathPatterns("/swagger-ui.html")
                .excludePathPatterns("/configuration/ui")
                .excludePathPatterns("/swagger-resources")
                .excludePathPatterns("/configuration/security")
                .excludePathPatterns("/v2/api-docs")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/**/favicon.ico");
        super.addInterceptors(registry);
    }

}
